cssshadowvalue: Handle error condition propertly
authorMatthias Clasen <mclasen@redhat.com>
Wed, 17 Mar 2021 11:49:06 +0000 (07:49 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 17 Mar 2021 11:49:06 +0000 (07:49 -0400)
We were parsing off the end of our array before noticing
that we've gone too far. gcc 11 warns about this.

gtk/gtkcssshadowvalue.c

index 86dfcafdfb6f942547c5e0b4650248ef03724cca..94fccffd820a9be07ff5a753b2c90b593c69f52c 100644 (file)
@@ -494,14 +494,14 @@ gtk_css_shadow_value_parse (GtkCssParser *parser,
     return gtk_css_shadow_value_new_none ();
 
   do {
-    if (gtk_css_shadow_value_parse_one (parser, box_shadow_mode, &shadows[n_shadows]))
-      n_shadows++;
-
-    if (n_shadows > MAX_SHADOWS)
+    if (n_shadows == MAX_SHADOWS)
       {
-        gtk_css_parser_error_syntax (parser, "Not more than 64 shadows supported");
+        gtk_css_parser_error_syntax (parser, "Not more than %d shadows supported", MAX_SHADOWS);
         goto fail;
       }
+    if (gtk_css_shadow_value_parse_one (parser, box_shadow_mode, &shadows[n_shadows]))
+      n_shadows++;
+
   } while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
 
   return gtk_css_shadow_value_new (shadows, n_shadows, FALSE);